﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace SacMauVN
{
    public partial class DanhSachSanPham : System.Web.UI.Page
    {
        private static int cID;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["cID"] != null)
            {
                cID = Convert.ToInt32(Request.QueryString["cID"]);
                LoadListSanPham(cID);
            }
            else
            {
                LoadListSanPham();
            }
        }

        private void LoadListSanPham(int MenuID)
        {
            string sql = "SELECT * FROM tblSMVNSanPham WHERE Menu_ID = @Menu_ID";
            List<SqlParameter> arrParams = new List<SqlParameter>();
            arrParams.Add(SqlHelper.CreateParameterObject("@Menu_ID", SqlDbType.Int, ParameterDirection.Input, MenuID));
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql, arrParams);
            rptListProduct.DataSource = dt;
            rptListProduct.DataBind();
        }

        private void LoadListSanPham()
        {
            string sql = "SELECT * FROM tblSMVNSanPham";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            rptListProduct.DataSource = dt;
            rptListProduct.DataBind();
        }
    }
}
